package com.ruoyi.pos.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.pos.domain.ExchangeOrder;
import com.ruoyi.pos.service.IExchangeOrderService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * exchange_orderController
 * 
 * @author ruoyi
 * @date 2021-05-21
 */
@RestController
@RequestMapping("/dev-api/system/pos/pos/exchange_order")
public class ExchangeOrderController extends BaseController
{
    @Autowired
    private IExchangeOrderService exchangeOrderService;

    /**
     * 查询exchange_order列表
     */
//    @PreAuthorize("@ss.hasPermi('pos:order:list')")
    @GetMapping("/list")
    public TableDataInfo list(ExchangeOrder exchangeOrder)
    {
        startPage();
        List<ExchangeOrder> list = exchangeOrderService.selectExchangeOrderList(exchangeOrder);
        return getDataTable(list);
    }

    /**
     * 导出exchange_order列表
     */
//    @PreAuthorize("@ss.hasPermi('pos:order:export')")
    @Log(title = "exchange_order", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(ExchangeOrder exchangeOrder)
    {
        List<ExchangeOrder> list = exchangeOrderService.selectExchangeOrderList(exchangeOrder);
        ExcelUtil<ExchangeOrder> util = new ExcelUtil<ExchangeOrder>(ExchangeOrder.class);
        return util.exportExcel(list, "order");
    }

    /**
     * 获取exchange_order详细信息
     */
//    @PreAuthorize("@ss.hasPermi('pos:order:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(exchangeOrderService.selectExchangeOrderById(id));
    }

    /**
     * 新增exchange_order
     */
//    @PreAuthorize("@ss.hasPermi('pos:order:add')")
    @Log(title = "exchange_order", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ExchangeOrder exchangeOrder)
    {
        return toAjax(exchangeOrderService.insertExchangeOrder(exchangeOrder));
    }

    /**
     * 修改exchange_order
     */
//    @PreAuthorize("@ss.hasPermi('pos:order:edit')")
    @Log(title = "exchange_order", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ExchangeOrder exchangeOrder)
    {
        return toAjax(exchangeOrderService.updateExchangeOrder(exchangeOrder));
    }

    /**
     * 删除exchange_order
     */
//    @PreAuthorize("@ss.hasPermi('pos:order:remove')")
    @Log(title = "exchange_order", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(exchangeOrderService.deleteExchangeOrderByIds(ids));
    }
}
